﻿$(document).ready(function () {
    // Jump to bestelform after posting the form with the resolution
    if ($('#bestellen').length === 1 && $('.bestelbutton').length === 1) {
        $('html, body').animate({
            scrollTop: $("#bestellen").offset().top
        }, 1);
    }

    // Show/hide reaction form.
    if ($('.mediaObjectDetailReaction form').length === 1 && $('#customShowHideReactionForm').length === 1) {
        var $f = $('.mediaObjectDetailReaction form');
        var $b = $('#customShowHideReactionForm');
        var openClass = 'opened';
        var closedClass = 'closed';
        $f.hide().removeClass('');
        $b.on('click', function () {
            if (!$f.hasClass(openClass)) {
                $f.slideDown('fast').removeClass(closedClass).addClass(openClass);
            } else {
                $f.slideUp('fast').addClass(closedClass).removeClass(openClass);
            }
        });
    }
});